﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Default.Master" AutoEventWireup="true"
  CodeBehind="PriceList.aspx.cs" Inherits="SaleManagement.Web.Pages.PriceList" %>

<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxHiddenField" TagPrefix="dxhf" %>
<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dxpc" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dxcb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  <table width="100%">
    <tr>
      <td class="search_header" colspan="7">
        Danh sách giá sản phẩm
      </td>
    </tr>
    <tr>
      <td style="height: 19px; width: 100px;">
        <asp:Literal ID="Literal5" runat="server" Text="Loại sản phẩm"></asp:Literal>
        :
      </td>
      <td style="height: 19px; width: 130px">
        <dxe:ASPxComboBox Width="120px" ID="cbxSearchProductType" ClientInstanceName="cbxSearchProductType"
          runat="server" CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua"
          LoadingPanelText="" TextField="Name" ValueField="Id" ValueType="System.Int32" ImageFolder="~/App_Themes/Aqua/{0}/"
          ShowShadow="False">
          <ValidationSettings>
            <ErrorImage Height="14px" Url="~/App_Themes/Aqua/Editors/edtError.png" Width="14px" />
            <ErrorFrameStyle ImageSpacing="4px">
              <ErrorTextPaddings PaddingLeft="4px" />
            </ErrorFrameStyle>
          </ValidationSettings>
          <ButtonEditEllipsisImage Height="3px" Url="~/App_Themes/Aqua/Editors/edtEllipsis.png"
            UrlDisabled="~/App_Themes/Aqua/Editors/edtEllipsisDisabled.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtEllipsisHottracked.png"
            UrlPressed="~/App_Themes/Aqua/Editors/edtEllipsisPressed.png" Width="12px" />
          <DropDownButton>
            <Image Height="7px" Url="~/App_Themes/Aqua/Editors/edtDropDown.png" UrlDisabled="~/App_Themes/Aqua/Editors/edtDropDownDisabled.png"
              UrlHottracked="~/App_Themes/Aqua/Editors/edtDropDownHottracked.png" UrlPressed="~/App_Themes/Aqua/Editors/edtDropDownPressed.png"
              Width="9px" />
          </DropDownButton>
          <ClientSideEvents SelectedIndexChanged="function(s,e){onCbxSearchProductType_IndexChanged(s,e)}" />
        </dxe:ASPxComboBox>
      </td>
      <td style="height: 19px; width: 10px;">
      </td>
      <td style="height: 19px; width: 100px;">
        <asp:Literal ID="Literal6" runat="server" Text="Sản phẩm"></asp:Literal>
        :
      </td>
      <td style="height: 19px; width: 130px">
        <dxe:ASPxComboBox Width="120px" ID="cbxSearchProduct" ClientInstanceName="cbxSearchProduct"
          runat="server" CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua"
          LoadingPanelText="" TextField="Name" ValueField="Id" ValueType="System.Int32" ImageFolder="~/App_Themes/Aqua/{0}/"
          ShowShadow="False" OnCallback="cbxSearchProduct_Callback">
          <ButtonEditEllipsisImage Height="3px" Url="~/App_Themes/Aqua/Editors/edtEllipsis.png"
            UrlDisabled="~/App_Themes/Aqua/Editors/edtEllipsisDisabled.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtEllipsisHottracked.png"
            UrlPressed="~/App_Themes/Aqua/Editors/edtEllipsisPressed.png" Width="12px" />
          <DropDownButton>
            <Image Height="7px" Url="~/App_Themes/Aqua/Editors/edtDropDown.png" UrlDisabled="~/App_Themes/Aqua/Editors/edtDropDownDisabled.png"
              UrlHottracked="~/App_Themes/Aqua/Editors/edtDropDownHottracked.png" UrlPressed="~/App_Themes/Aqua/Editors/edtDropDownPressed.png"
              Width="9px" />
          </DropDownButton>
          <ValidationSettings>
            <ErrorImage Height="14px" Url="~/App_Themes/Aqua/Editors/edtError.png" Width="14px" />
            <ErrorFrameStyle ImageSpacing="4px">
              <ErrorTextPaddings PaddingLeft="4px" />
            </ErrorFrameStyle>
          </ValidationSettings>
        </dxe:ASPxComboBox>
      </td>
      <td style="width: 100px; "">
        <dxe:ASPxButton ID="ASPxButton1" runat="server" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
          CssPostfix="Aqua" Text="Tìm kiếm" ClientInstanceName="btnSearch">
          <Image Url="../Images/find.png" />
          <ClientSideEvents Click="function(s,e){onbtnSearch(s,e);e.processOnServer=false;}" />
        </dxe:ASPxButton>
      </td>
      <td>
      </td>
    </tr>
  </table>
  <div>
    <dxwgv:ASPxGridView ID="gvPrice" ClientInstanceName="gvPrice" runat="server" Width="100%"
      CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua" OnCustomCallback="gvPrice_CustomCallback"
      OnCustomJSProperties="gvPrice_CustomJSProperties" OnPageIndexChanged="gvPrice_PageIndexChanged"
      AutoGenerateColumns="False" KeyFieldName="ShipID;SeatClassId">
      <SettingsBehavior AllowDragDrop="False" AllowGroup="False" AllowSort="False" />
      <Styles CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua">
      </Styles>
      <SettingsLoadingPanel Text="" />
      <SettingsPager>
        <AllButton>
          <Image Height="19px" Width="27px" />
        </AllButton>
        <FirstPageButton>
          <Image Height="19px" Width="23px" />
        </FirstPageButton>
        <LastPageButton>
          <Image Height="19px" Width="23px" />
        </LastPageButton>
        <NextPageButton>
          <Image Height="19px" Width="19px" />
        </NextPageButton>
        <PrevPageButton>
          <Image Height="19px" Width="19px" />
        </PrevPageButton>
      </SettingsPager>
      <Images ImageFolder="~/App_Themes/Aqua/{0}/">
        <HeaderSortDown Height="5px" Width="7px" Url="~/App_Themes/Aqua/GridView/gvHeaderSortDown.png" />
        <CollapsedButton Height="15px" Width="15px" Url="~/App_Themes/Aqua/GridView/gvCollapsedButton.png" />
        <ExpandedButton Height="15px" Width="15px" Url="~/App_Themes/Aqua/GridView/gvExpandedButton.png" />
        <DetailCollapsedButton Height="15px" Width="15px" Url="~/App_Themes/Aqua/GridView/gvDetailCollapsedButton.png" />
        <DetailExpandedButton Height="15px" Width="15px" Url="~/App_Themes/Aqua/GridView/gvDetailExpandedButton.png" />
        <HeaderFilter Height="19px" Url="~/App_Themes/Aqua/GridView/gvHeaderFilter.png" Width="19px" />
        <HeaderActiveFilter Height="19px" Url="~/App_Themes/Aqua/GridView/gvHeaderFilterActive.png"
          Width="19px" />
        <HeaderSortUp Height="5px" Width="7px" Url="~/App_Themes/Aqua/GridView/gvHeaderSortUp.png" />
        <FilterRowButton Height="13px" Width="13px" />
        <WindowResizer Height="13px" Width="13px" Url="~/App_Themes/Aqua/GridView/WindowResizer.png" />
      </Images>
      <StylesEditors>
        <ProgressBar Height="25px">
        </ProgressBar>
      </StylesEditors>
      <ImagesEditors>
        <CalendarFastNavPrevYear Height="19px" Url="~/App_Themes/Aqua/Editors/edtCalendarFNPrevYear.png"
          Width="19px" />
        <CalendarFastNavNextYear Height="19px" Url="~/App_Themes/Aqua/Editors/edtCalendarFNNextYear.png"
          Width="19px" />
        <DropDownEditDropDown Height="7px" Url="~/App_Themes/Aqua/Editors/edtDropDown.png"
          UrlDisabled="~/App_Themes/Aqua/Editors/edtDropDownDisabled.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtDropDownHottracked.png"
          Width="9px" />
        <SpinEditIncrement Height="6px" Url="~/App_Themes/Aqua/Editors/edtSpinEditIncrementImage.png"
          UrlDisabled="~/App_Themes/Aqua/Editors/edtSpinEditIncrementDisabledImage.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtSpinEditIncrementHottrackedImage.png"
          UrlPressed="~/App_Themes/Aqua/Editors/edtSpinEditIncrementHottrackedImage.png"
          Width="7px" />
        <SpinEditDecrement Height="7px" Url="~/App_Themes/Aqua/Editors/edtSpinEditDecrementImage.png"
          UrlDisabled="~/App_Themes/Aqua/Editors/edtSpinEditDecrementDisabledImage.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtSpinEditDecrementHottrackedImage.png"
          UrlPressed="~/App_Themes/Aqua/Editors/edtSpinEditDecrementHottrackedImage.png"
          Width="7px" />
        <SpinEditLargeIncrement Height="9px" Url="~/App_Themes/Aqua/Editors/edtSpinEditLargeIncImage.png"
          UrlDisabled="~/App_Themes/Aqua/Editors/edtSpinEditLargeIncDisabledImage.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtSpinEditLargeIncHottrackedImage.png"
          UrlPressed="~/App_Themes/Aqua/Editors/edtSpinEditLargeIncHottrackedImage.png" Width="7px" />
        <SpinEditLargeDecrement Height="9px" Url="~/App_Themes/Aqua/Editors/edtSpinEditLargeDecImage.png"
          UrlDisabled="~/App_Themes/Aqua/Editors/edtSpinEditLargeDecDisabledImage.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtSpinEditLargeDecHottrackedImage.png"
          UrlPressed="~/App_Themes/Aqua/Editors/edtSpinEditLargeDecHottrackedImage.png" Width="7px" />
      </ImagesEditors>
      <ClientSideEvents EndCallback="function (s,e){ongvPrice_EndCallback(s,e);}" />
      <Columns>
        <dxwgv:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="3" Caption="Sản phẩm">
          <HeaderStyle HorizontalAlign="Center" />
        </dxwgv:GridViewDataTextColumn>
        <dxwgv:GridViewDataTextColumn FieldName="Price" VisibleIndex="3" Caption="Giá bán">
          <PropertiesTextEdit DisplayFormatString="#,###,##0">
          </PropertiesTextEdit>
          <HeaderStyle HorizontalAlign="Center" />
        </dxwgv:GridViewDataTextColumn>
        <dxwgv:GridViewDataTextColumn FieldName="EffectiveDate" VisibleIndex="3" Caption="Ngày hiệu lực">
          <PropertiesTextEdit DisplayFormatString="dd/MM/yyyy HH:mm">
          </PropertiesTextEdit>
          <HeaderStyle HorizontalAlign="Center" />
          <CellStyle HorizontalAlign="Center" />
        </dxwgv:GridViewDataTextColumn>
      </Columns>
    </dxwgv:ASPxGridView>
  </div>
  <div style="padding-top: 5px;">
    <dxe:ASPxButton ID="btnAdd" runat="server" Text="Thêm mới" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
      CssPostfix="Aqua" AutoPostBack="False">
      <Image Url="../Images/add.png" />
      <ClientSideEvents Click="function(s, e) {
	onAdd();e.processOnServer = false;}" />
    </dxe:ASPxButton>
  </div>
  <div>
    <dxpc:ASPxPopupControl ID="pcAddPrice" ClientInstanceName="pcAddPrice" runat="server"
      CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua" ImageFolder="~/App_Themes/Aqua/{0}/"
      Width="320px" PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter"
      HeaderText="Điều chỉnh giá bán" CloseAction="CloseButton" Modal="True">
      <ContentStyle VerticalAlign="Top">
      </ContentStyle>
      <SizeGripImage Height="12px" Width="12px" />
      <SizeGripImage Height="12px" Width="12px"></SizeGripImage>
      <ContentCollection>
        <dxpc:PopupControlContentControl>
          <div>
            <dxe:ASPxLabel ID="lblErrorMessage" ClientInstanceName="lblErrorMessage" runat="server"
              Font-Bold="True" ForeColor="#FF3300" Font-Names="Tahoma" Font-Size="8pt" Font-Strikeout="False">
            </dxe:ASPxLabel>
          </div>
          <table class="">
            <tr>
              <td style="width: 120px">
                <asp:Label ID="Label1" runat="server" Text="Loại sản phẩm"></asp:Label>
                :
              </td>
              <td style="padding-left: 3px;">
                <dxe:ASPxComboBox Width="170px" ID="cbxProductType" ClientInstanceName="cbxProductType"
                  runat="server" CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua"
                  LoadingPanelText="" TextField="Name" ValueField="Id" ValueType="System.Int32" ImageFolder="~/App_Themes/Aqua/{0}/"
                  ShowShadow="False">
                  <DropDownButton>
                    <Image Height="7px" Url="~/App_Themes/Aqua/Editors/edtDropDown.png" UrlDisabled="~/App_Themes/Aqua/Editors/edtDropDownDisabled.png"
                      UrlHottracked="~/App_Themes/Aqua/Editors/edtDropDownHottracked.png" UrlPressed="~/App_Themes/Aqua/Editors/edtDropDownPressed.png" />
                  </DropDownButton>
                  <ButtonEditEllipsisImage Height="3px" Url="~/App_Themes/Aqua/Editors/edtEllipsis.png"
                    UrlDisabled="~/App_Themes/Aqua/Editors/edtEllipsisDisabled.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtEllipsisHottracked.png"
                    UrlPressed="~/App_Themes/Aqua/Editors/edtEllipsisPressed.png" />
                  <ValidationSettings>
                    <ErrorImage Height="14px" Url="~/App_Themes/Aqua/Editors/edtError.png" />
                    <ErrorFrameStyle ImageSpacing="4px">
                      <ErrorTextPaddings PaddingLeft="4px" />
                    </ErrorFrameStyle>
                  </ValidationSettings>
                  <ClientSideEvents SelectedIndexChanged="function(s,e){onCbxProductType_IndexChanged(s,e)}" />
                </dxe:ASPxComboBox>
              </td>
            </tr>
            <tr>
              <td>
                <asp:Label ID="lblProduct" runat="server" Text="Sản phẩm"></asp:Label>
                :
              </td>
              <td style="padding-left: 3px;">
                <dxe:ASPxComboBox Width="170px" ID="cbxProduct" ClientInstanceName="cbxProduct" runat="server"
                  CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua" LoadingPanelText=""
                  TextField="Name" ValueField="Id" ValueType="System.Int32" ImageFolder="~/App_Themes/Aqua/{0}/"
                  ShowShadow="False" OnCallback="cbxProduct_Callback">
                  <DropDownButton>
                    <Image Height="7px" Url="~/App_Themes/Aqua/Editors/edtDropDown.png" UrlDisabled="~/App_Themes/Aqua/Editors/edtDropDownDisabled.png"
                      UrlHottracked="~/App_Themes/Aqua/Editors/edtDropDownHottracked.png" UrlPressed="~/App_Themes/Aqua/Editors/edtDropDownPressed.png" />
                  </DropDownButton>
                  <ButtonEditEllipsisImage Height="3px" Url="~/App_Themes/Aqua/Editors/edtEllipsis.png"
                    UrlDisabled="~/App_Themes/Aqua/Editors/edtEllipsisDisabled.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtEllipsisHottracked.png"
                    UrlPressed="~/App_Themes/Aqua/Editors/edtEllipsisPressed.png" />
                  <ValidationSettings>
                    <ErrorImage Height="14px" Url="~/App_Themes/Aqua/Editors/edtError.png" />
                    <ErrorFrameStyle ImageSpacing="4px">
                      <ErrorTextPaddings PaddingLeft="4px" />
                    </ErrorFrameStyle>
                  </ValidationSettings>
                </dxe:ASPxComboBox>
              </td>
            </tr>
            <tr>
              <td>
                <asp:Label ID="lblPrice" runat="server" Text="Giá"></asp:Label>
                :
              </td>
              <td>
                <dxe:ASPxTextBox ID="txtPrice" ClientInstanceName="txtPrice" runat="server" Width="170px"
                  CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua">
                  <MaskSettings IncludeLiterals="None" Mask="&lt;0..9999999999g&gt;" />
                  <ValidationSettings ErrorDisplayMode="None">
                    <ErrorImage Height="14px" Url="~/App_Themes/Aqua/Editors/edtError.png" />
                    <ErrorFrameStyle ImageSpacing="4px">
                      <ErrorTextPaddings PaddingLeft="4px" />
                    </ErrorFrameStyle>
                  </ValidationSettings>
                </dxe:ASPxTextBox>
              </td>
            </tr>
            <tr>
              <td>
                <asp:HiddenField runat="server" ID="hfPriceId" />
              </td>
              <td style="padding-top: 4px; padding-left: 3px;">
                <div style="float: left;">
                  <dxe:ASPxButton ID="btnSave" runat="server" Text="Lưu" AutoPostBack="False" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
                    CssPostfix="Aqua">
                    <Image Url="../Images/save.png" />
                    <ClientSideEvents Click="function(s, e) {
	                      onSave();}" />
                  </dxe:ASPxButton>
                </div>
                <div style="float: left; padding-left: 3px;">
                  <dxe:ASPxButton ID="btnCancel" runat="server" Text="Đóng" AutoPostBack="False" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
                    CssPostfix="Aqua">
                    <Image Url="../Images/cancel.png" />
                    <ClientSideEvents Click="function(s, e) {
	                          onCancel(); e.processOnServer = false;}" />
                  </dxe:ASPxButton>
                </div>
              </td>
            </tr>
          </table>
        </dxpc:PopupControlContentControl>
      </ContentCollection>
      <CloseButtonImage Height="16px" Width="18px" />
      <CloseButtonImage Height="18px" Width="18px"></CloseButtonImage>
      <HeaderStyle Font-Bold="True" ForeColor="#59A1EF" />
    </dxpc:ASPxPopupControl>
  </div>

  <script type="text/javascript" language="javascript">

    function onAdd() {
      ResetValue();
      pcAddPrice.Show();
    }
    function ResetValue() {
      document.getElementById('<%=hfPriceId.ClientID %>').value = '';
      cbxProduct.SetValue(null);
      txtPrice.SetText('');
      lblErrorMessage.SetText('');
    }
    function onSave() {
      if (validateInput()) {
        gvPrice.PerformCallback('Save|');
      }
    }
    function onCancel() {
      pcAddPrice.Hide();
    }

    function validateInput() {
      var error = '';
      if (txtPrice.GetText() == '' || txtPrice.GetText() == '0')
        error += '<BR> + Giá';
      if (cbxProduct.GetValue() == null || cbxProduct.GetValue() == '') error += '<BR> + Sản phẩm';
      if (error != '') {
        error = 'Bạn phải điền vào các ô sau:' + error;
        lblErrorMessage.SetText(error);
        return false;
      }
      return true;
    }

    function ongvPrice_EndCallback(s, e) {
      var error = gvPrice.cpInnerError.split('|');
      if (error[0] == 'Save') {
        if (error[1] != '')
          lblErrorMessage.SetText(error[1]);
        else {
          pcAddPrice.Hide();
          alert('Cập nhật dữ liệu thành công');
        }
      }
    }

    function onCbxSearchProductType_IndexChanged(s, e) {
      cbxSearchProduct.PerformCallback();
    }

    function onCbxProductType_IndexChanged(s, e) {
      cbxProduct.PerformCallback();
    }

    function onbtnSearch(s, e) {
      gvPrice.PerformCallback();
    }
  </script>

</asp:Content>
